package com.ymatou.iapi.godmch.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.godmch.parameter.createmchBean;
import com.ymatou.iapi.godmch.parameter.editRemarkCSBean;
import com.ymatou.iapi.godmch.service.editRemarkCSCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.cs_info;
import com.ymttest.database.sqlwapper.godmch.DefGodMchWapper;
/**
*设置客服备注
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_editRemarkCS{
	private static editRemarkCSBean editremarkcsBean;
	private static editRemarkCSCall editremarkcsCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("设置客服备注");
	}

	@Before
	public void caseUp() {
		editremarkcsBean=new editRemarkCSBean();
		editremarkcsCall=new editRemarkCSCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(editremarkcsCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editRemarkCS_001() {
		Logger.start(true,"设置客服备注,验证商户id与客服id匹配,返回成功");
		try {
			Integer templateId=1;
			int mchId=GodmchManageCallService.CreateSellerMch();
	        UserCreateBean usercreateBean= DGUserCallService.initCsUsercreateBean();
	        Integer csId=DGUserCallService.UserCreateCall(usercreateBean);
	        GodmchManageCallService.CreateCSCall(mchId, csId, templateId);
	        
	        editremarkcsBean.setCsId(csId);
	        editremarkcsBean.setMchId(mchId);
	        editremarkcsBean.setRemark("remark");
			editremarkcsCall.setData(editremarkcsBean);
			editremarkcsCall.callService();			
			Logger.verifyEquals("200", editremarkcsCall.getString("status"), "验证status");
			cs_info csi = new DefGodMchWapper().selectCsInfo(mchId, csId).get(0);
			Logger.verifyEquals(editremarkcsBean.getRemark(), csi.getRemark(), "验证remark");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editRemarkCS_002() {
		Logger.start(true,"设置客服备注,验证商户id与客服id不匹配,返回失败");
		try {
			Integer templateId=1;
			int mchId=GodmchManageCallService.CreateSellerMch();
	        UserCreateBean usercreateBean= DGUserCallService.initCsUsercreateBean();
	        Integer csId=DGUserCallService.UserCreateCall(usercreateBean);
	        GodmchManageCallService.CreateCSCall(mchId, csId, templateId);
	        
	        editremarkcsBean.setCsId(csId);
	        editremarkcsBean.setMchId(mchId+1);
	        editremarkcsBean.setRemark("remark");
			editremarkcsCall.setData(editremarkcsBean);
			editremarkcsCall.callService();			
			Logger.verifyEquals("5023", editremarkcsCall.getString("status"), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editRemarkCS_003() {
		Logger.start(true,"设置客服备注,客服已删除,返回错误");
		try {
			Integer templateId=1;
			int mchId=GodmchManageCallService.CreateSellerMch();
	        UserCreateBean usercreateBean= DGUserCallService.initCsUsercreateBean();
	        Integer csId=DGUserCallService.UserCreateCall(usercreateBean);
	        GodmchManageCallService.CreateCSCall(mchId, csId, templateId);
	        GodmchManageCallService.RemoveCs(mchId, csId);
	        editremarkcsBean.setCsId(csId);
	        editremarkcsBean.setMchId(mchId);
	        editremarkcsBean.setRemark("remark");
			editremarkcsCall.setData(editremarkcsBean);
			editremarkcsCall.callService();			
			Logger.verifyEquals("5023", editremarkcsCall.getString("status"), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editRemarkCS_005() {
		Logger.start(true,"设置客服备注,验证商户id为空,返回错误");
		try {
			editremarkcsBean.setCsId(1);
	        editremarkcsBean.setMchId(null);
	        editremarkcsBean.setRemark("remark");
			editremarkcsCall.setData(editremarkcsBean);
			editremarkcsCall.callService();			
			Logger.verifyEquals("4001", editremarkcsCall.getString("status"), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editRemarkCS_006() {
		Logger.start(true,"设置客服备注,验证客服id为空,返回错误");
		try {
			editremarkcsBean.setCsId(null);
	        editremarkcsBean.setMchId(1);
	        editremarkcsBean.setRemark("remark");
			editremarkcsCall.setData(editremarkcsBean);
			editremarkcsCall.callService();			
			Logger.verifyEquals("4001", editremarkcsCall.getString("status"), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editRemarkCS_007() {
		Logger.start(true,"设置客服备注,验证备注为空,返回错误");
		try {
			editremarkcsBean.setCsId(1);
	        editremarkcsBean.setMchId(1);
	        editremarkcsBean.setRemark(null);
			editremarkcsCall.setData(editremarkcsBean);
			editremarkcsCall.callService();			
			Logger.verifyEquals("4001", editremarkcsCall.getString("status"), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}